home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 012a / lib194.zip / HELPROC.PRG < prev    next >
Text File  |  1993-01-19  |  7KB  |  215 lines

  1. *-------------------------------------------------------------------------------
  2. *-- Program...: HELPROC.PRG
  3. *-- Programmer: Bowen Moursund (CIS: 76566,1405)
  4. *-- Date......: 01/19/1993
  5. *-- Notes.....: This is designed to be a black-box procedure to handle help
  6. *--             screens for the user. See directions in HELPER below. Suggest
  7. *--             using this with SET PROC TO HELPROC or better yet: 
  8. *--                SET LIBR TO HELPROC
  9. *--             This requires the use of HELPER.DBF and HELPER.FMT.
  10. *-------------------------------------------------------------------------------
  11.  
  12. PROCEDURE Helper
  13. *-------------------------------------------------------------------------------
  14. *-- Programmer..: Bowen Moursund (CIS: 76566,1405)
  15. *-- Date........: 01/19/1993
  16. *-- Notes.......: Helper is a procedure for displaying help text in a full
  17. *--               screen browse. The text is stored in a DBF file:
  18. *--
  19. *--               Structure for database: HELPER.DBF
  20. *--               Field  Field Name  Type       Width    Dec    Index
  21. *--                   1  HELP        Character     78               N
  22. *--
  23. *--               The help text may be loaded into the DBF by creating a
  24. *--               text file using a text editor, and importing the contents
  25. *--               of that file into helper.dbf in this fashion:
  26. *--
  27. *--               . use helper
  28. *--               . zap
  29. *--               . append from <text filename> sdf
  30. *--
  31. *--               Helper is designed to be called as an program interrupt
  32. *--               by the key label F1. Make sure to include the line
  33. *--
  34. *--               on key label F1 do helper
  35. *--
  36. *--               near the beginning of the application. The format file
  37. *--               Helper.fmt must be included with the application.
  38. *--
  39. *-- Written for.: dBASE IV, 1.5
  40. *-- Rev. History: None
  41. *-- Calls.......: StrSrch              Procedure in HELPROC.PRG (below)
  42. *--               HELPER.FMT
  43. *--               HELPER.DBF
  44. *-- Called by...: None
  45. *-- Usage.......: on key label F1 do helper
  46. *-- Example.....: see above
  47. *-- Returns.....: Nothing
  48. *-- Parameters..: None
  49. *-- WARNING.....: Do not use this procedure if it might interrupt a dBASE
  50. *--               BEGIN TRANSACTION. Helper opens and closes helper.dbf, and
  51. *--               DBFs cannot be closed while a dBASE transaction is in
  52. *--               progress.
  53. *-------------------------------------------------------------------------------
  54.  
  55.     on key label F1 ?? ""  && disable interrupt
  56.     private cAlias, cFormat, lTalkOn, lCursOn, lScoreOn, lClockOn, lStatOn, ;
  57.             lLoop, cStr
  58.     lTalkOn = ( set( "talk" ) = "ON" )
  59.     set talk off
  60.     cStr = space(15)  && to be used by search utility
  61.     save screen to sHelpScr
  62.     *-- save environment
  63.     cAlias = alias()
  64.     cFormat = set( "format" )
  65.     lCurson = ( set( "cursor" ) = "ON" )
  66.     lScoreOn = ( set( "scoreboard" ) = "ON" )
  67.     lClockOn = ( set( "clock" ) = "ON" )
  68.     lStatOn = ( set( "status" ) = "ON" )
  69.     lConsOff = ( set( "console" ) = "OFF" )
  70.     lPrintOn = ( set( "printer" ) = "ON" )
  71.     lFieldsOn = ( set( "fields" ) = "ON" )
  72.  
  73.     set printer off
  74.     set console on
  75.     set fields off
  76.  
  77.     define window wHelper from 0,0 to 23,79 none
  78.     select select()
  79.     use helper
  80.     set format to helper
  81.     set clock off
  82.     set cursor off
  83.     set scoreboard off
  84.     lLoop = .t.
  85.     if lStaton
  86.         set status off
  87.     endif
  88.     on key label F1 do strsrch
  89.     activate window wHelper
  90.     do while lLoop
  91.         lLoop = .f.  && procedure strsrch might set this .t.
  92.         browse noappend noclear nomenu noedit nodelete compress format
  93.     enddo
  94.     deactivate window wHelper
  95.     on key label F1 ?? ""
  96.     use
  97.  
  98.     *-- restore environment
  99.     if lScoreOn
  100.         set scoreboard on
  101.     endif
  102.     if lCurson
  103.         set cursor on
  104.     endif
  105.     if lClockOn
  106.         set clock on
  107.     endif
  108.     if "" # cAlias
  109.         select ( cAlias )
  110.     endif
  111.     if "" # cFormat
  112.         set format to ( cFormat )
  113.     endif
  114.     if lStatOn
  115.         set status on
  116.     endif
  117.     if lConsOff
  118.         set console off
  119.     endif
  120.     if lPrintOn
  121.          set printer on
  122.     endif
  123.     if lFieldsOn
  124.         set fields on
  125.     endif
  126.     if lTalkOn
  127.         set talk on
  128.     endif
  129.  
  130.     release window wHelper
  131.     restore screen from sHelpScr
  132.     release screen sHelpScr
  133.     on key label F1 do helper
  134.  
  135. RETURN
  136. *-- EoP: Helper
  137.  
  138. PROCEDURE StrSrch
  139. *-------------------------------------------------------------------------------
  140. *-- Programmer..: Bowen Moursund (CIS: 76566,1405)
  141. *-- Date........: 01/19/1993
  142. *-- Notes.......: String search procedure for PROCEDURE Helper
  143. *-- Written for.: dBASE IV, 1.5
  144. *-- Rev. History: None
  145. *-- Calls.......: None
  146. *-- Called by...: Helper               Procedure in HELPROC.PRG (above)
  147. *-- Usage.......: Do StrSrch
  148. *-- Example.....: See above
  149. *-- Returns.....: None
  150. *-- Parameters..: None
  151. *-------------------------------------------------------------------------------
  152.  
  153.     on key label F1 ?? ""  && disable interrupt
  154.     private cTrimStr, cSearchStr, lSearchLoop
  155.     close format  && gotta close format because of the search string read
  156.     lSearchLoop = .t.
  157.     define window wStrSrch from 15,19 to 21,59
  158.     define window w_Shadow from 16,17 to 22,57 none color n/n,n/n
  159.     activate window w_Shadow
  160.     activate window wStrSrch
  161.     @1,10 say "HELP Search Utility"
  162.  
  163.     do while lSearchLoop
  164.         @3,0
  165.         *-- cStr initialized in procedure helper
  166.         @3,4 say "Search string " + chr(16) get cStr function "!" ;
  167.          message "Enter search string.    Esc: Cancel"
  168.         set cursor on
  169.         read
  170.         set cursor off
  171.         cTrimStr = ltrim( rtrim( cStr ) )
  172.         if lastkey() # 27 .and. "" # cTrimStr
  173.             nRecNo = recno()
  174.             cSearchStr = upper( cTrimStr )
  175.             lFound = .f.
  176.             if .not. eof()
  177.                 * look for next occurrence of cSearchStr
  178.                 do while .not. eof() .and. .not. lFound
  179.                     skip
  180.                     lFound = ( cSearchStr $ upper( help ) )
  181.                 enddo
  182.             endif
  183.             if .not. lFound
  184.                 @3,0
  185.                 ?? chr(7)
  186.                 @3,20 - (len(cTrimStr+" not found.")/2) say cTrimStr + ;
  187.                   " not found."
  188.                 i = inkey(3)
  189.                 goto nRecNo
  190.                 lSearchLoop = .t.
  191.             else
  192.                 *-- lLoop initialized in procedure helper
  193.                 lLoop = .t.  && re-browse after terminating
  194.                 lSearchLoop = .f.
  195.                 keyboard chr(23)  && terminate the browse
  196.             endif
  197.         else
  198.             lSearchLoop = .f.  && exit the loop
  199.         endif
  200.     enddo
  201.  
  202.     deactivate window wStrSrch
  203.     deactivate window w_Shadow
  204.     release window wStrSrch
  205.     release window w_Shadow
  206.     set format to helper
  207.     on key label F1 do strsrch
  208.  
  209. RETURN
  210. *-- EoP: StrSrch
  211.  
  212. *-------------------------------------------------------------------------------
  213. *-- End of Program: HELPROC.PRG
  214. *-------------------------------------------------------------------------------
  215.